<template>
  <div class="addmpany">

      <div class="company-wrapper">
      <!-- <div class="header" >完善企业信息</div> -->
        <div class="item">
          <select_self  
            arrTag="企业名称"
              @getItem="getCompany"
                @getSearch="getSearch"
                api="https://www.rzkeji.com/api/ucenter/companyInfoSearch"
                params="key_word"
                :initcompanyName='initcompanyName'
                ></select_self>
        </div>
        <div class="item">
        <div class="item-name">职位</div>
        <input type="text" placeholder="请输入职位" v-model="position">
      </div>
      <!-- <div class="item">
        <div class="item-name">企业经营范围</div>
        <input type="text" placeholder="请输入企业经营范围" v-model="companyRange">
      </div>
      <div class="item item-profile">
        <div class="item-name">企业简介</div>
      </div>
      <textarea   placeholder="输入企业简介"  class="text-area" v-model="companyBrief"/>
      <div class="img-list">
        <upLoadImgMy @getImgIdList="getProfileImg($event,index)" :imgListInit="imgListInit"></upLoadImgMy>
      </div> -->
      
    <div @click="userBindCompany" class="company-btn" v-if="clickFlag">添加企业</div>
    <div  class="company-btn disabled-btn" v-else>添加企业</div>
    <div class="tip">温馨提示：若搜索不到您的企业，请联系管理员添加企业信息</div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      clickFlag:'',
      initcompanyName:'',
      position:'',
      companyMsg:'',//企业信息
    }
  },
  methods: {
    getSearch(e){
      // console.log(e,'b')
    },
    getCompany(e){
      //获取搜索的企业
      if(e.mp.detail==false){
        //添加按钮变灰
        this.clickFlag=false
      }else{
        this.clickFlag=true;
        this.companyMsg=e.mp.detail
      }
    },
    async userBindCompany(){
      //绑定企业
      const userToken=wx.getStorageSync('userToken');
      const res=await this.$api.userBindCompany({
        type:'',
        user_token:userToken,
        company_id:this.companyMsg.id,
        position:this.position
      })
      this.$currency.showToast(res.data.message)
      if(res.data.level=='success'){
        setTimeout(()=>{
          this.$currency.redirectTo('/pages/meMain/myCompany/main');
        },2000)
      }
    },
    initData(){
      this.clickFlag='';
      this.initcompanyName='';
      this.position='';
      this.companyMsg='';//企业信息
    }
  },
  onLoad(){
    this.initData()
  }
}
</script>

<style lang="scss" scoped>
    @mixin baseBtn{
      color:#fff;
      background-color: rgb(22, 155, 213);
      text-align: center;
      border-radius:10px;
    }
    .header{
      font-weight: 600;
      padding:20px 0;
      
    }
    .addmpany{
      width:calc(100% - 20px);
      margin-left:10px;
    }
    .item-tag{
      flex-wrap: wrap;
    }
    .item-profile{
      border-bottom: none !important;
    }
    .item{
      display:flex;
      align-items: center;
      border-bottom: 1px solid #eee;
      padding:15px 0;
      position: relative;
      picker{
        flex:1
      }
      .delete{
      width:40px;
      height: 40px;
      position: absolute;
      top:-20px;
      left: -20px;
    }
      .item-name{
        min-width: 100px;
        white-space: nowrap;
        margin-right: 20px;
      }
      .tag-list{
        border-radius: 10px;
        margin-top:20px;
        width: 100%;
        display:flex;
        flex-wrap: wrap;
        align-content: flex-start;
        padding:5px;
        img{
          width:20px;
          height: 20px;
          position: absolute;
          right:-10px;
          top:-10px;
        }
      }
      .tag-list-item{
        border:1px solid #eee;
        height: 30px;
        line-height: 30px;
        border-radius: 5px;
        padding:0 2px;
        margin:0 15px 15px 0;
        position: relative;
      }
      .tag-input{
        flex:1;
        height: 30px;
        line-height: 30px;
      }
      .add-tag{
        @include baseBtn;
        width:70px;
        height: 30px;
        line-height: 30px;
      }
      .picker{
        color:gray;
      }
      .upload-img{
        color:#fff;
        background-color: rgb(22, 155, 213);
        padding: 5px 15px;
        border-radius: 5px
      }
      select_self{
        flex:1;
      }
    }
    .text-area{
        border: 1px  solid gray;
        min-height: 60px;
        border-radius: 5px;
        width: 100%;
        box-sizing: border-box;
      }

    
    .company-btn{
      margin: 20px 60px 60px 60px;
      color:#fff;
      background-color: rgb(22, 155, 213);
      border-radius: 5px;
      padding:10px;
      text-align:center;

    }
    .disabled-btn{
      background: gray;
    }
    .submit-wrapper{
      width: 100%;
      display: flex;
      justify-content: center;
      
      .submit{
      @include baseBtn;
      padding:10px 0;
      position:fixed;
      z-index:9999;
      bottom:0px;
      width:90%;
    }
    }
    
    .company-wrapper{
      padding-bottom:10px;
    }
</style>

